import http from "@/api/config";
import { root } from "../config";
// import axios from "axios";

/**
 * 首页数据信息
 * @param id
 * @param callback
 */
const homeData = (callback) => {
  var url = root + "/Classify/homeData";

  http.post(url).then(res => {
    callback(res.data);
  });
};

/**
 * 分类导航
 * @param id
 * @param callback
 */
const getClassAll = (callback) => {
  var url = root + "/Classify/getClassAll";

  http.post(url).then(res => {
    callback(res.data);
  });

    // axios.post(url).then((res) => {
    //   callback(res.data);
    // });

};

/**
 * 分类导航
 * @param id
 * @param callback
 */
const getClassInfoById = (id,callback) => {
  var url = root + "/Classify/getClassInfoById";

  let data = new FormData();
  data.append("id", id);

  http.post(url,data).then(res => {
    callback(res.data);
  });

};



/**
 * 根据ID，获取广告信息
 * @param id
 * @param callback
 */
const getListClid = (id,size,page,callback) => {
  var url = root + "/Classify/getListClid";

  let data = new FormData();
  data.append("id", id);
  data.append("size", size);
  data.append("page", page);

  http.post(url,data).then(res => {
    callback(res.data);
  });
};

/**
 * 根据ID查询详情
 */
const getContentInfoById = (id,callback) => {
  var url = root + "/Classify/getContentInfoById";

  let data = new FormData();
  data.append("id", id);

  http.post(url,data).then(res => {
    callback(res.data);
  });
};


/**
 * 根据ID查询详情
 */
const readRight = (callback) => {
  var url = root + "/Classify/readRight";

  http.post(url).then(res => {
    callback(res.data);
  });
};

/**
 * 根据ID查询详情
 */
const getAllClssById = (id,callback) => {
  var url = root + "/Classify/getAllClssById";
  let data = new FormData();
  data.append("id", id);
  http.post(url,data).then(res => {
    callback(res.data);
  });
};

/**
 * 根据时间获取交易日历
 */
const getInfolistByTime = (time,callback) => {
  var url = root + "/Classify/getInfolistByTime";
  let data = new FormData();
  data.append("time", time);
  http.post(url,data).then(res => {
    callback(res.data);
  });
};

/**
 * 分类导航
 * @param id
 * @param callback
 */
const getAllByFid = (id,callback) => {
  var url = root + "/Classify/getAllByFid";

  let data = new FormData();
  data.append("fid", id);

  http.post(url,data).then(res => {
    callback(res.data);
  });

};

/**
 * 根据月份查询哪些某月的那几天有交易日历数据
 * @param month  2021-02
 * @param callback
 */
const getListByMonth = (month,callback) => {
  var url = root + "/Classify/getListByMonth";

  let data = new FormData();
  data.append("month", month);

  http.post(url,data).then(res => {
    callback(res.data);
  });

};


export {
  homeData,
  getListClid,
  getClassAll,
  getContentInfoById,
  readRight,
  getAllClssById,
  getInfolistByTime,
  getClassInfoById,
  getAllByFid,
  getListByMonth
};
